layui.use(['form','layer'],function(){
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;
    form.on("submit(addPhotoParam)",function(data){
        var arr = new Array();
        //弹出loading
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        // 实际使用时的提交信息
        $.post("/photoParamAdd", {
            xxId: $("#xxId").val(),
            spid: data.field.spid,
            bkColor: data.field.bkColor
        }, function (data) {
            if (data =="success"||data.includes("success")) {
                top.layer.close(index);
                var msg = "添加成功!";
                msg = data.lastIndexOf("@@")!=-1?msg+data.split("@@")[1]:msg;
                top.layer.msg(msg);
                layer.closeAll("iframe");
                //刷新父页面
                parent.location.reload();
            }else if (data == "error") {
                top.layer.msg("添加失败！");
            }else{
                top.layer.msg(data);
            }
        });
        return false;
    });
    //格式化时间
    function filterTime(val){
        if(val < 10){
            return "0" + val;
        }else{
            return val;
        }
    }
    //定时发布
    var time = new Date();
    var submitTime = time.getFullYear()+'-'+filterTime(time.getMonth()+1)+'-'+filterTime(time.getDate())+' '+filterTime(time.getHours())+':'+filterTime(time.getMinutes())+':'+filterTime(time.getSeconds());

})